﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using DiagramDesigner;

namespace DemoApp
{
    public class ComponentList : INPCBase
    {
        private Dictionary<int, string> componentList;

        public ComponentList()
        {
            this.componentList = new Dictionary<int, string>();
        }

        public ComponentList(Dictionary<int, string> components)
        {
            this.componentList = components;
        }

        public Dictionary<int, string> Components
        {
            get
            {
                return this.componentList;
            }
            set
            {
                if (this.componentList != value)
                {
                    this.componentList = value;
                    NotifyChanged("ComponentList");
                }
            }
        }

        public void AddComponent(int index, string name)
        {
            componentList.Add(index, name);
        }

        public string GetComponent(int index)
        {
            string value;
            if (componentList.TryGetValue(index, out value))
            {
                return value;
            }
            else
                return null;
        }
    }
}
